<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript">
        //ES5
        //$( ) -->> jquery的工厂函数--->> 生成对象
        //          -->> 把DOM对象转换成jquery对象
        //ajax异步访问json
        var test = function(){
            $("#name").text("加载...");
            $.ajax({
                url:"json1",
                data: {name: "小花",age: 3},
                dataType:"json",
                success:function(res) {
                    $("#name").text(res.name);
                    $("#age").text(res.age);
                },
                error:function(){
                    alert('网络不给力，请稍后再试');
                },
            });
        };
    </script>
</head>
<body>
<button onclick="test()">ajax异步访问点击</button>
<div id="name"></div>
<div id="age"></div>
</body>
</html>